package com.zuser.project.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zuser.project.dao.CustomerInfoDao;
import com.zuser.project.entity.CustomerInfoEntity;
import com.zuser.project.service.CustomerInfoService;
import com.zuser.project.util.R;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoDao, CustomerInfoEntity> implements CustomerInfoService {




    @Override
    public R queryPage(Map<String, Object> params) {
        System.out.println("获取这个数据成功");
        QueryWrapper<CustomerInfoEntity> queryWrapper = new  QueryWrapper<>();
        if (params.get("nickname")!=null&&params.get("nickname")!="")
        {
            queryWrapper.eq("nickname",params.get("nickname"));
        }
        Page<CustomerInfoEntity> customerInfoEntityPage = new Page<>(Integer.parseInt(params.get("page").toString()),Integer.parseInt(params.get("limit").toString()));
        Page<CustomerInfoEntity> page = this.page(customerInfoEntityPage, queryWrapper);
        Map<String, Object> map = new HashMap<>();

        map.put("list",page.getRecords());
        map.put("totalCount",page.getTotal());
        return R.ok("获取这个数据成功").put("page",map);
    }

}